package com.kinon.bs_app.fragments;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.kinon.bs_app.R;
import com.kinon.bs_app.adapter.MarketAdapter;

public class XuanbiFragment extends Fragment implements View.OnClickListener {

    private View mView = null;

    private Button btn_zixuan = null;
    private Button btn_dingpan = null;
    private Button btn_jingqingqidai = null;

    private TextView tv_time = null;

    private ListView lv_list = null;
    private MarketAdapter adapter = null;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_xuanbi, container, false);
        return mView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        initListener();
    }

    private void initView() {
        btn_zixuan = mView.findViewById(R.id.btn_zixuan);
        btn_dingpan = mView.findViewById(R.id.btn_dingpan);
        btn_jingqingqidai = mView.findViewById(R.id.btn_jingqingqidai);

        btn_zixuan.setCompoundDrawables(null,
                stardardImg(R.drawable.img_zixuan),null,null);
        btn_dingpan.setCompoundDrawables(null,
                stardardImg(R.drawable.img_dingpan), null,null);
        btn_jingqingqidai.setCompoundDrawables(null,
                stardardImg(R.drawable.img_jingqingqidai), null,null);

        tv_time = mView.findViewById(R.id.tv_time);

        lv_list = mView.findViewById(R.id.lv_list);
    }

    private void initListener() {
        btn_zixuan.setOnClickListener(this);
        btn_dingpan.setOnClickListener(this);
        btn_jingqingqidai.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_zixuan:
                break;
            case R.id.btn_dingpan:
                break;
            case R.id.btn_jingqingqidai:
                break;
            default:
                break;
        }
    }

    public Drawable stardardImg(int position) {
        Drawable drawable = getResources().getDrawable(position);
        drawable.setBounds(0, 0, 80, 80);
        return drawable;
    }
}
